"""
整合内建工具：wikipedia
pip install -qU wikipedia
工具的官网：https://python.langchain.com/v0.2/docs/integrations/tools/wikipedia/
"""
from langchain_community.tools import WikipediaQueryRun
from langchain_community.utilities import WikipediaAPIWrapper

## top_k_results=1: 只要一个结果，doc_content_chars_max=100 字数最大100
api_wrapper = WikipediaAPIWrapper(top_k_results=1, doc_content_chars_max=100)
tool = WikipediaQueryRun(api_wrapper=api_wrapper)
print(tool.invoke({"query": "langchain"}))

print(f"名称：{tool.name}")
print(f"描述：{tool.description}")
print(f"参数：{tool.args}")
print(f"returns directly?: {tool.returns_directly()}")

